package com.tmy.controller;

import com.tmy.Dto.PageInfo;
import com.tmy.Dto.Result;
import com.tmy.entity.Order;
import com.tmy.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 订单管理接口
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;


    /**
     * 新增订单
     */
    @PostMapping("/addOrder")
    public Result addOrder(@RequestBody Order order){
        return orderService.addOrder(order);
    }
    /**
     * 删除订单
     */
    @PostMapping("/deleteOrder")
    public Result deleteOrder(@RequestBody Order order){
        return orderService.deleteOrder(order);
    }
    /**
     * 修改订单
     */
    @PostMapping("/updateOrder")
    public Result updateOrder(@RequestBody Order order){
        return orderService.updateOrder(order);
    }
    /**
     * 查询订单（用户自己）
     */
    @PostMapping("/queryOrder")
    public Result queryOrder(@RequestBody Order order){
        return orderService.queryOrder(order);
    }
    /**
     * 查询订单（分页查询）
     */
    @PostMapping("/queryOrderPage")
    public Result queryOrderPage(@RequestBody PageInfo pageInfo){
        return orderService.queryOrderPage(pageInfo);
    }
}
